home *** CD-ROM | disk | FTP | other *** search
- /*************************************************************************************
- *
- * Generic Appshell- a system 7.0 compatible application shell
- *
- * ©1992 Graham Cox. All Rights Reserved.
- *
- * This file contains code which may require modification to incorporate your
- * application's functionality. This file contains menu disatch functions.
- *
- * Modification History:
- * 10/2/92 created from scratch.
- *
- *
- *
- *************************************************************************************/
-
- #include "PDPGlobalEqu.p"
- #include "EditGlobalEqu.p"
-
- #include "PDPMenus.proto.h"
-
- textEdHdl GetWEditRecord(WindowPtr theWindow);
- char IsEditKind(WindowPtr);
-
- extern int done;
- extern MenuHandle AppMenus[NumMenus];
-
- int AssemblyDest = toMemory;
-
- ProcessRecHdl GetProcess(WindowPtr theWindow);
- PDPRegHdl GetCPU(WindowPtr theWindow);
- PDPMemHdl GetMemory(WindowPtr theWindow);
- PrefsRecHdl GetPrefs(WindowPtr theWindow);
- int SetTargetProcess(long currentProcess);
-
-
-
- FileMenu(int theItem)
- {
- /* handle file menu commands */
- SFReply fReply;
-
- switch (theItem) {
- case ItemNew:
- OpenNewWindow();
- break;
- case ItemOpen:
- OpenSourceCode();
- break;
- case ItemClose:
- CloseTheWindow(FrontWindow());
- break;
- case ItemSaveAs:
- case ItemSave:
- break;
- case ItemPageSetup:
- break;
- case ItemPrint:
- break;
- case ItemQuit:
- done = TRUE;
- break;
- default:
- break;
- }
- }
-
-
- EditMenu(int theItem)
- {
- /* handle edit menu commands */
-
- if (! SystemEdit(theItem-1)) {
- switch(theItem) {
- case ItemUndo:
- break;
- case ItemCut:
- break;
- case ItemCopy:
- break;
- case ItemPaste:
- break;
- case ItemClear:
- break;
- case ItemShowClip:
- break;
- default:
- break;
- }
- }
- }
-
-
- PDPMenu(int theItem)
- {
- /* dispatches menu selections from PDP-8 menu */
- Str32 mString;
-
- switch (theItem) {
- case ItemGo:
- ResumePDP(FrontWindow());
- break;
- case ItemHalt:
- StopPDP(FrontWindow());
- break;
- case ItemReset:
- ResetPDP(FrontWindow());
- break;
- case ItemSingleStep:
- StepPDP(FrontWindow());
- break;
- case ItemScrollToPC:
- ScrollToPC(FrontWindow());
- break;
- case ItemGetInfo:
- ClearProcessMem(FrontWindow());
- MarkForUpdate(FrontWindow());
- break;
- case ItemPreferences:
- PDPPreferences(GetPrefs(FrontWindow()));
- MarkForUpdate(FrontWindow());
- break;
- case ItemStack:
- StackWindows();
- break;
- case ItemShowRuler:
- if (ShowHideRulers(FrontWindow()))
- /* showing ruler */
- GetIndString(&mString,standardResID,13);
- else
- /* hiding ruler */
- GetIndString(&mString,standardResID,12);
- SetItem(AppMenus[pdpMenu],ItemShowRuler,&mString);
- break;
- default:
- break;
- }
- }
-
-
- AssembleMenu(MenuHandle theMenu,int theItem)
- {
- /* dispatches commands from assemble menu */
- int aHit;
- SFReply fReply;
- extern int TargetProcessID;
-
- switch (theItem) {
- case ItemAssemble:
- PDPAssembleCode(FrontWindow());
- break;
- case ItemToDisk:
- CheckItem(theMenu,ItemToMemory,FALSE);
- CheckItem(theMenu,ItemToDisk,TRUE);
- AssemblyDest = toDisk;
- break;
- case ItemToMemory:
- CheckItem(theMenu,ItemToMemory,TRUE);
- CheckItem(theMenu,ItemToDisk,FALSE);
- AssemblyDest = toMemory;
- TargetProcessID = SetTargetProcess(TargetProcessID);
- break;
- case ItemToBasingstoke:
- aHit = xAlert(133,NIL);
- break;
- case ItemLoadObject:
- ChooseObjectFile(&fReply);
- PDPLoad(FrontWindow(),&fReply);
- break;
- default:
- break;
- }
- }
-
-
- OpenNewWindow(void)
- {
- /* opens new untitled window from default res template */
-
- WindowPtr w;
-
- w = GetNewWindow(standardResID,NIL,(WindowPtr)-1L);
- if (w != NIL) {
- InitProcessWindow(w);
- ShowWindow(w);
- SelectWindow(w);
- }
- }
-
-
- ChooseObjectFile(SFReply *theReply)
- {
- /* presents SF Open dialog box for object files */
-
- SFTypeList theList;
- Point where;
-
- theList[0] = 'OBJF';
- SetPt(&where,100,100);
- SFDialogLocation(getDlgID,&where);
- SFGetFile(where,(ConstStr255Param)'/p',NIL,2,&theList,NIL,theReply);
- }
-
-
- MenuAdjust(void)
- {
- /* call before a menu selection to enable/disable items according to current window
- type at front */
- int i,th;
- textEdHdl theText;
- Str32 mTxt;
-
- if (IsSimulator(FrontWindow())) {
- EnableItem(AppMenus[pdpMenu],ItemScrollToPC);
- EnableItem(AppMenus[pdpMenu],ItemPreferences);
- EnableItem(AppMenus[asmMenu],ItemLoadObject);
- }
- else {
- DisableItem(AppMenus[pdpMenu],ItemScrollToPC);
- DisableItem(AppMenus[pdpMenu],ItemPreferences);
- DisableItem(AppMenus[asmMenu],ItemLoadObject);
- }
- if (IsEditKind(FrontWindow())) {
- theText = GetWEditRecord(FrontWindow());
- th = GetTabBarHeight(theText);
- if (th)
- GetIndString(&mTxt,standardResID,13);
- else
- GetIndString(&mTxt,standardResID,12);
- SetItem(AppMenus[pdpMenu],ItemShowRuler,&mTxt);
- EnableItem(AppMenus[asmMenu],ItemAssemble);
- EnableItem(AppMenus[pdpMenu],ItemShowRuler);
- }
- else {
- DisableItem(AppMenus[asmMenu],ItemAssemble);
- DisableItem(AppMenus[pdpMenu],ItemShowRuler);
- }
- }